const cookie = function (req, res, next) {
  // 通过尾调用，实现数据的传递
  if (req && res) {
    // 解析cookie
    next();
  }
};

const logger = function (req, res, next) {
  // 通过触发next
  if (res) {
  } else {
    next();
  }
};

// app.use()

interface appCOM {
  req: String;
  res: String;
  //   next: () => void;
  use: () => void;
}

class appC<appCOM> {
  req: String;
  res: String;
  constructor(req: string, res: string) {
    this.req = req;
    this.res = res;
  }

  static use(middle: Function): void {
    let middleList: Function[] = [];
    if (!middleList.includes(middle)) {
      middleList = [...middleList, middle];
    }
    middle && middle();
  }
}

appC.use(cookie);
